/*
 * 全部条目访问
 * 
 * 用于预付卡全卡数据作图功能
 * 
*/

	package dao;

	import java.sql.Connection;
	import java.sql.DriverManager;
	import java.sql.ResultSet;
	import java.sql.Statement;

import context.Context;
import exception.ViewException;

	public class TotalRecordDAO {

		public static ResultSet getTotalRecord(int quaryCondition) throws ViewException
		{
			Context c = Context.newInstance();
			
			Statement st = null;

			ResultSet rs = null;

			//ResultSetMetaData rsmd = null;
			
			String quaryClause = "";

			if(quaryCondition%2==0)
				quaryClause = quaryClause +"tradeType = 'Z3004' or ";
			if(quaryCondition%3==0)
				quaryClause = quaryClause +"tradeType = '00F00900' or ";
			if(quaryCondition%5==0)
				quaryClause = quaryClause +"tradeType = '01C00121' or ";
			if(quaryCondition%7==0)
				quaryClause = quaryClause +"tradeType = '01C00820' or ";
			quaryClause = quaryClause + " false";
			
			String tableName = "newpayrecord";
			
			try {

				Class.forName("com.mysql.jdbc.Driver");


				Connection con = DriverManager.getConnection(c.getConnection(), c.getUsrName(),
						c.getPsw());

				st = con.createStatement();

				String sqltotal = "select tradeDate, sum(amount) from newpayrecord where "
					+ quaryClause
					+ " group by tradeDate";
								
				
				rs = st.executeQuery(sqltotal);

				//rsmd = rs.getMetaData();
				

			} catch (Exception e) {

				e.printStackTrace();
				throw new ViewException("查询出错，请重启再试");
			}
			return rs;
		}
		
	}

